package com.design.state.vending;

// 状态接口
interface VendingMachineState {
    void insertCoin();
    void dispense();
}

// 具体状态类 - 有货物
class HasItemState implements VendingMachineState {
    @Override
    public void insertCoin() {
        System.out.println("Coin inserted. Item ready for dispense.");
    }

    @Override
    public void dispense() {
        System.out.println("Dispensing item.");
    }
}

// 具体状态类 - 售空
class EmptyState implements VendingMachineState {
    @Override
    public void insertCoin() {
        System.out.println("No item available.");
    }

    @Override
    public void dispense() {
        System.out.println("No item to dispense.");
    }
}

// 具体状态类 - 投币
class InsertCoinState implements VendingMachineState {
    @Override
    public void insertCoin() {
        System.out.println("Coin already inserted.");
    }

    @Override
    public void dispense() {
        System.out.println("Coin inserted. Item dispensed.");
    }
}
